# Maintainer: Antonio Rojas <arojas@archlinux.org>

pkgname=shared_meataxe
pkgver=1.0.1
pkgrel=1
pkgdesc="A set of programs for working with matrix representations over finite fields"
arch=(loong64 x86_64)
url="https://users.minet.uni-jena.de/~king/SharedMeatAxe/"
license=(GPL)
depends=(glibc)
conflicts=(meataxe)
replaces=('meataxe<=2.4.24-6')
source=(https://github.com/simon-king-jena/SharedMeatAxe/releases/download/v$pkgver/$pkgname-$pkgver.tar.bz2)
sha256sums=('b8c5ff558712b266eef76a4ebc7a06e98cdef04cc46c542a1a725e318365969d')

build() {
  cd $pkgname-$pkgver
  ./configure --prefix=/usr
  make
}

package() {
  cd $pkgname-$pkgver
  make DESTDIR="$pkgdir" install

  mkdir -p "$pkgdir"/usr/share/meataxe
# Build multiplication tables
  cd "$pkgdir"/usr/share/meataxe
  for i in 2 3 4 5 7 8 9 11 13 16 17 19 23 25 27 29 31 32 37 41 43 47 49 53 59 61 64 67 71 73 79 81 83 89 97 101 103 107 109 113 121 125 \
           127 128 131 137 139 149 151 157 163 167 169 173 179 181 191 193 197 199 211 223 227 229 233 239 241 243 251
  do
    LD_PRELOAD=../../lib/libmtx.so ../../bin/zcv <(echo "matrix field=$i rows=0 cols=0") /dev/null
  done
}
